function z = dot(x,y)
if ~isa(y,'deriv1s')
  z.v = dot(x.v,y);
  z.d = y(:)' * squeeze(x.d);
elseif ~isa(x,'deriv1s')
  z.v = dot(x,y.v);
  z.d = x(:)' * squeeze(y.d);
else
  z.v = dot(x.v,y.v);
  z.d = x.v(:)'*squeeze(y.d) + y.v(:)'*squeeze(x.d);
end

z=class(z,'deriv1s');

